<?php
/**
 * Copyright (c) 2006, PORTALIER Julien
 *
 * Some parts are copyright (c) CakePHP,
 * @link http://cakephp.org/
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @package      FeatherPHP
 * @subpackage   Core
 * @copyright    Copyright (c) 2006, Julien PORTALIER
 * @link         http://feather.portalier.com
 * @license      http://www.opensource.org/licenses/mit-license.php The MIT License
 */

// paths
define('DS',       DIRECTORY_SEPARATOR);
define('WWW_ROOT', dirname(__FILE__).DS);
define('APP',      dirname(WWW_ROOT).DS);
define('ROOT',     dirname(APP).DS);
define('FEATHER',  ROOT.'feather2'.DS);

// base functions
require FEATHER.'basics.php';

// URI
$uri = preg_replace(':^/:', '', isset($_GET['url']) ? $_GET['url'] : env('PATH_INFO'));

if (!preg_match(':/$:', $uri))
	$uri = "$uri/";
if (isset($uri) && $uri === 'favicon.ico')
	die();

$_GET['url'] = $uri;

// full URL prefix
$https = env('HTTPS');
define('PROTOCOL', 'http'.((isset($https) && $https == 'on') ? 's' : null).'://');

$httpHost = env('HTTP_HOST');
if (isset($httpHost))
	define('FULL_BASE_URL', PROTOCOL.$httpHost);

unset($https, $httpHost);

// feather's core
require FEATHER.'libs'.DS.'base.php';
require APP.'config'.DS.'core.php';
require FEATHER.'libs'.DS.'dispatcher.php';

// dispatching
Dispatcher::dispatch($uri);
?>